home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 31.6 KB | 806 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
- { UGridView.p }
- { Copyright © 1987-1990 by Apple Computer Inc. All rights reserved. }
-
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := FALSE}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT UGridView;
-
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED __UGridView__}
- {$SETC __UGridView__ := FALSE}
- {$ENDC}
-
- {$IFC NOT __UGridView__}
- {$SETC __UGridView__ := TRUE}
-
- { • Auto-Include the requirements for this unit's interface. }
- {$SETC UGridViewIncludes := UsingIncludes}
- {$SETC UsingIncludes := TRUE}
- {$I+}
- {$IFC UNDEFINED __UMacApp__} {$I UMacApp.p} {$ENDC}
- {$SETC UsingIncludes := UGridViewIncludes}
-
- CONST
-
- { Booleans for Adornment }
- kAdorn = TRUE;
- kDontAdorn = FALSE;
-
- { Booleans for SetSelection }
- kExtend = TRUE;
- kDontExtend = FALSE;
-
- kHighlight = TRUE;
- kDontHighlight = FALSE;
-
- kSelect = TRUE;
- kDeSelect = FALSE;
-
- TYPE
- GridCell = Point; { A cell is a QuickDraw point }
-
- GridViewPart = (badChoice, inCell, inRow, inColumn, inVertex);
-
- {--------------------------------------------------------------------------------------------------}
-
- RunArrayChunk = RECORD
- count: INTEGER; { Number of consecutive items with this
- value }
- value: INTEGER; { The value represented by this chunk }
- END;
-
- ChunkArray = ARRAY [0..100000] OF RunArrayChunk;
- ChunkArrayPtr = ^ChunkArray; { Preferred }
- ChunkArrayHandle = ^ChunkArrayPtr; { Preferred }
- PChunkArray = ChunkArrayPtr; { Left in for compatibility (2.0) }
- HChunkArray = ChunkArrayHandle; { Left in for compatibility (2.0) }
-
- TRunArray = OBJECT (TObject) { The run array class is used to maintain
- the column widths and row heights. Entries
- in the array are values for a given item,
- where the items are indexed from one.
- fNoOfItems indicates the number of items
- (and values) in the array. The values are
- maintained in "chunks" which lump together
- consecutive items with the same value. A
- variable length array, fChunks, is used to
- store the chunks. It is indexed from zero.
- }
- fLastItem: INTEGER; { cache the last item found }
- fLastChunk: INTEGER; { cache the last chunk found }
-
- fLastTotal: LONGINT; { cache the last total calculated }
- fLastIndex: INTEGER; { cache the last index used }
- fNoOfItems: INTEGER; { Number of items (values) in this run-array
- }
- fTotal: LONGINT; { The sum of the values in the run array }
- fNoOfChunks: INTEGER; { Number of chunks in the run array }
- fChunks: ChunkArrayHandle; { A handle to the chunks themselves. }
-
- PROCEDURE TRunArray.IRunArray;
- { Initializes a run array to have zero items. }
-
- PROCEDURE TRunArray.Free; OVERRIDE;
- { Frees the fChunks field which is a handle to the chunks, before calling inherited
- Free. }
-
- PROCEDURE TRunArray.InsertItems(firstItem, noOfItems: INTEGER;
- value: INTEGER);
- { Inserts the indicated items into the run array, all of which have the given value.
- }
-
- PROCEDURE TRunArray.DeleteItems(firstItem, noOfItems: INTEGER);
- { Deletes the indicated items from the run array.}
-
- FUNCTION TRunArray.FindChunk(item: INTEGER;
- VAR chunk, indexInChunk: INTEGER;
- VAR theTotal: LONGINT): BOOLEAN;
- { Returns information about a given item in the run array. chunk indicates the chunk
- in which the item is located, where zero is the first chunk in the run array.
- indexInChunk is the location of the item withinin the chunk. Note that the chunk
- indexes are one-based--the first item in the chunk is index 1. theTotal is the sum
- of values up to, but not including, the chunk in which the given item is located.
- FindChunk returns false if the given item is outside the range of items in the
- run-array (i.e. item < 1 or item > fNoOfItems), or the given item is not
- represented in a chunk (i.e. a bug).
- Example: Item Value Chunk indexInChunk theTotal
- 1 05 0 1 000
- 2 05 0 2 000
- 3 20 1 1 010
- 4 35 2 1 030
- 5 35 2 2 030
- 6 10 3 1 100
- }
-
- FUNCTION TRunArray.FindItem(theTotal: LONGINT): INTEGER;
- { Returns the item number for which the sum of the values exceeds theTotal, or zero
- if theTotal is outside the sum of values represented by the run array.}
-
- FUNCTION TRunArray.GetValue(item: INTEGER): INTEGER;
- { Returns the value for the given item. }
-
- FUNCTION TRunArray.SumValues(firstItem, noOfItems: INTEGER): LONGINT;
- { Returns the sum of the values over the given items. }
-
- PROCEDURE TRunArray.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
-
- GridViewTemplate = PACKED RECORD
- numOfRows: INTEGER;
- numOfCols: INTEGER;
- rowHeight: INTEGER;
- colWidth: INTEGER;
- rowInset: INTEGER;
- colInset: INTEGER;
- adornRows: BOOLEAN;
- adornCols: BOOLEAN;
- singleSelection: BOOLEAN;
- filler: 0..8191;
- END;
- GridViewTemplatePtr = ^GridViewTemplate;
-
- TextGridViewTemplate = PACKED RECORD
- itsFontFace: Style;
- itsFontSize: INTEGER;
- itsFontColor: RGBColor;
- itsFontName: Str255; { a variable length P-String }
- END;
- TextGridViewTemplatePtr = ^TextGridViewTemplate;
-
- TGridView = OBJECT (TView) { TGridView forms the base class for a
- building block that allows the creation of
- views that can contain and manage cells,
- similar to a spreadsheet. }
- fNumOfRows: INTEGER; { number of rows }
- fNumOfCols: INTEGER; { number of columns }
- fColWidths: TRunArray; { bag containing col widths }
- fRowHeights: TRunArray; { bag containing row heights }
- fAdornRows: BOOLEAN; { Draw adornment for rows? }
- fAdornCols: BOOLEAN; { Draw adornment for columns? }
- fRowInset: INTEGER; { Number of pixels between cell rows }
- fColInset: INTEGER; { Number of pixels between cell cols }
- fSingleSelection: BOOLEAN; { only one cell selected at a time? }
- fSelections: RgnHandle; { Region of currently selected cells }
- fHLRegion: RgnHandle; { Region of cells to be highlighted. This
- will be different from fSelections while
- selection with the mouse is taking place.
- }
- fTempSelections: RgnHandle; { Used by SetSelectionRect }
-
- PROCEDURE TGridView.IGridView(itsDocument: TDocument; { Its document }
- itsSuperView: TView; { Its parent view }
- itsLocation: VPoint; { Top, Left in parent's coords }
- itsSize: VPoint; { Ignored for sizeVariable }
- itsHSizeDet, itsVSizeDet: SizeDeterminer; { Size
- determiners }
- numOfRows: INTEGER; { number of rows initially }
- numOfCols: INTEGER; { number of columns initially }
- rowHeight: INTEGER; { Height for initial rows }
- colWidth: INTEGER; { width for initial columns }
- adornRows: BOOLEAN; { Adornment for Rows? }
- adornCols: BOOLEAN; { Adornment for Columns? }
- rowInset: INTEGER; { horizontal space between cells }
- colInset: INTEGER; { vertical space between cells }
- singleSelection: BOOLEAN); { single cell selection? }
-
- { Initialize the gridview. If numOfRows or numOfCols is non-zero then the gridview is
- initialized to the specified size using rowHeight and colWidth if the sizedeterminer
- is sizeVariable. If either adorn is kDontAdorn, then that adorn will not be called. }
-
- PROCEDURE TGridView.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TGridView.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write this object out as a view resource. }
-
- PROCEDURE TGridView.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TGridView.Free; OVERRIDE;
- { Free the TGridView object }
-
- { Methods to OVERRIDE }
-
- { Inherited Methods (OVERRIDE) }
-
- PROCEDURE TGridView.CalcMinSize(VAR minSize: VPoint); OVERRIDE;
- { Sets the extent of the view. }
-
- PROCEDURE TGridView.DoHighlightSelection(fromHL, toHL: HLState); OVERRIDE;
- { Do highlighting }
-
- FUNCTION TGridView.DoMouseCommand(VAR theMouse: Point;
- VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
- { Handle mouse commands }
-
- PROCEDURE TGridView.Draw(area: Rect); OVERRIDE;
- { Calls DrawRangeOfCells and AdornRow/Col as appropriate. }
-
- { UGridView Methods to OVERRIDE }
-
- PROCEDURE TGridView.AdornCol(aCol: INTEGER;
- area: Rect);
- { If fAdornCol is TRUE, this method is called to draw the column adornments. }
-
- PROCEDURE TGridView.AdornRow(aRow: INTEGER;
- area: Rect);
- { If fAdornRow is TRUE, this method is called to draw the row adornments. }
-
- FUNCTION TGridView.CanSelectCell(aCell: GridCell): BOOLEAN;
- { This method checks to see if a cell can be seleced. By default, this method always
- returns TRUE. }
-
- PROCEDURE TGridView.HighlightCells(theCells: RgnHandle;
- fromHL, toHL: HLState);
- { Highlights the cells in theCells according to the given highlight state. }
-
- PROCEDURE TGridView.DrawRangeOfCells(startCell, stopCell: GridCell;
- aQDRect: Rect);
- { This method calls DrawCell for each cell in need of re-drawing. }
-
- PROCEDURE TGridView.DrawCell(aCell: GridCell;
- aQDRect: Rect);
- { This method draws each individual cell. IT MUST BE OVERRIDDEN! }
-
- { General UGridView Methods }
-
- PROCEDURE TGridView.AllCellsDo(PROCEDURE
- DoToCell(aCell: GridCell));
- { For every cell in the view perform "DoToCell". }
-
- PROCEDURE TGridView.CellToVRect(aCell: GridCell;
- VAR aRect: VRect);
- { Get the rectangle bounding a given cell. This includes the row and column insets. }
-
- PROCEDURE TGridView.ColToVRect(aCol: INTEGER;
- numOfCols: INTEGER;
- VAR aRect: VRect);
- { Get the rectangle bounding the given columns. This includes the cells in the row or
- column and the row or column insets. }
-
- PROCEDURE TGridView.RowToVRect(aRow: INTEGER;
- numOfRows: INTEGER;
- VAR aRect: VRect);
- { Get the rectangle bounding the given rows. This includes the cells in the row or
- column and the row or column insets. }
-
- PROCEDURE TGridView.CellsToPixels(theCells, thePixels: RgnHandle);
- { Returns in thePixels a region that contains all of the cells in theCells. }
-
- PROCEDURE TGridView.DelColAt(aCol: INTEGER;
- numOfCols: INTEGER);
- { Delete the specified columns, starting at 'aCol' with the number to be deleted
- 'numOfCols'.This causes a redraw of only the necessary cells. }
-
- PROCEDURE TGridView.DelRowAt(aRow: INTEGER;
- numOfRows: INTEGER);
- { Delete the specified rows, starting at 'aRow' with the number of to be deleted
- 'numOfRows'.This causes a redraw of only the necessary cells. }
-
- PROCEDURE TGridView.DelColFirst(numOfCols: INTEGER);
- { Delete the specified number of columns from the beginning of the list.This causes a
- redraw of only the necessary cells. }
-
- PROCEDURE TGridView.DelRowFirst(numOfRows: INTEGER);
- { Delete the specified number of rows from the beginning of the list.This causes a
- redraw of only the necessary cells. }
-
- PROCEDURE TGridView.DelColLast(numOfCols: INTEGER);
- { Delete the specified number of columns from the last cell of the list.This causes a
- redraw of only the necessary cells. }
-
- PROCEDURE TGridView.DelRowLast(numOfRows: INTEGER);
- { Delete the specified number of rows from the last cell of the list.This causes a
- redraw of only the necessary cells. }
-
- PROCEDURE TGridView.EachCellDo(startCell, stopCell: GridCell;
- PROCEDURE
- DoToCell(aCell: GridCell));
- { For each cell in the rectangle defined by startCell and stopCell perform
- "DoToCell". }
-
- PROCEDURE TGridView.EachSelectedCellDo(PROCEDURE
- DoToCell(aCell: GridCell));
- { For each cell in the selected region perform "DoToCell". }
-
- PROCEDURE TGridView.EachInRgn(aRgn: RgnHandle;
- PROCEDURE
- DoToCell(aCell: GridCell));
- { For each cell in the specified region perform "DoToCell". }
-
- FUNCTION TGridView.FirstSelectedCell: GridCell;
- { Returns the top left cell in the selection range, if any }
-
- FUNCTION TGridView.GetColWidth(aCol: INTEGER): INTEGER;
- { Return the width for the specified column. }
-
- FUNCTION TGridView.GetRowHeight(aRow: INTEGER): INTEGER;
- { Return the height for the specified row . }
-
- FUNCTION IdentifyPoint(theQDPoint: Point;
- VAR aRow, aCol: INTEGER): GridViewPart;
- { Return the GridViewPart (inCell, inColumn, inRow, inVertex)
- in which the specified point lies. The "vertex" is the area
- where a row and column meet. }
-
- PROCEDURE TGridView.InsColBefore(aCol: INTEGER;
- numOfCols: INTEGER;
- aWidth: INTEGER);
- { Insert the specified columns before the column given.The widths of the columns are
- all set to the specified aWidth. }
-
- PROCEDURE TGridView.InsRowBefore(aRow: INTEGER;
- numOfRows: INTEGER;
- aHeight: INTEGER);
- { Insert the specified rows before the row given.The heights of the rows are all set
- to the specified aHeight. }
-
- PROCEDURE TGridView.InsColFirst(numOfCols: INTEGER;
- aWidth: INTEGER);
- { Insert the specified number of columns at the beginning of the list.The widths of
- the columns are all set to the specified aWidth. }
-
- PROCEDURE TGridView.InsRowFirst(numOfRows: INTEGER;
- aHeight: INTEGER);
- { Insert the specified number of rows at the beginning of the list.The heights of the
- rows are all set to the specified aHeight. }
-
- PROCEDURE TGridView.InsColLast(numOfCols: INTEGER;
- aWidth: INTEGER);
- { Insert the specified number columns at the end of the list.The widths of the
- columns are all set to the specified aWidth. }
-
- PROCEDURE TGridView.InsRowLast(numOfRows: INTEGER;
- aHeight: INTEGER);
- { Insert the specified number of rows at the end of the list.The heights of the rows
- are all set to the specified aHeight. }
-
- PROCEDURE TGridView.InvalidateCell(aCell: GridCell);
- { Cause a cell to be marked invalid (in need of re-drawing). }
-
- PROCEDURE TGridView.InvalidateSelection;
- { Cause the rectangle bounding the selections to be marked
- invalid (in need of re-drawing). }
-
- FUNCTION TGridView.IsCellSelected(aCell: GridCell): BOOLEAN;
- { Check if the specified cell is currently selected. }
-
- FUNCTION TGridView.LastSelectedCell: GridCell;
- { Returns the bottom right cell in the selection range, if any }
-
- PROCEDURE TGridView.ScrollSelectionIntoView(redraw: BOOLEAN);
- { Scroll the specified rectangle into view. }
-
- PROCEDURE TGridView.SetColWidth(aCol: INTEGER;
- numOfCols: INTEGER;
- aWidth: INTEGER);
- { Set the width of the specified columns to that given. }
-
- PROCEDURE TGridView.SetRowHeight(aRow: INTEGER;
- numOfRows: INTEGER;
- aHeight: INTEGER);
- { Set the height of the specified rows to that given. }
-
- PROCEDURE TGridView.SelectCell(theCell: GridCell;
- extendSelection, highlight, select: BOOLEAN);
- { Set the current selection to the specified cell. Sets up a region and then calls
- SetSelection. }
-
- PROCEDURE TGridView.SetEmptySelection(highlight: BOOLEAN);
- { Set the current selection to be empty or nothing. If highlight is kHighlight then
- the appropriate highlighting is performed. }
-
- PROCEDURE TGridView.SetSelection(cellsToSelect: RgnHandle;
- extendSelection, highlight, select: BOOLEAN);
- { Set the current selections to the specified region. If extend is kExtend then
- cellsToSelect is "added" to that already selected, if highlight is kHighlight then
- cellsToSelect is highlighted as well. IF select is kSelect then cellsToSelect is
- selected, if kDeSelect then de-selected}
-
- PROCEDURE TGridView.SetSelectionRect(left, top, right, bottom: INTEGER;
- extendSelection, highlight, select: BOOLEAN);
- { Set the current selections to the specified rectangle. and call SetSelection. }
-
- PROCEDURE TGridView.SetSingleSelection(theSetting: BOOLEAN);
- { If TRUE then only one item/cell can be selected at a time }
-
- FUNCTION TGridView.VPointToCell(aPoint: VPoint): GridCell;
- { Determine the cell in which a given point lies, or (0, 0) if the given point
- doesn't lie within any cell. }
-
- FUNCTION TGridView.VPointToLastCell(aPoint: VPoint): GridCell;
- { Returns the cell in which the given point lies, or the last cell of the row/column
- if the horizontal/vertical coordinate lies beyond the last cell of the row/column.}
-
- { Debugging Methods }
-
- PROCEDURE TGridView.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- TTextGridView = OBJECT (TGridView) { A sub-class of TGridView that can handle
- the display of text in its cells. }
- fTextStyle: TextStyle; { The text style (color, size, etc. ) }
- fLineHeight: INTEGER; { height of each item including leading }
- fLineAscent: INTEGER; { pos. of baseline relative to top of line }
-
- { Initialization and Free Methods }
-
- PROCEDURE TTextGridView.ITextGridView(itsDocument: TDocument; { Its document }
- itsSuperView: TView; { Its parent view }
- itsLocation: VPoint; { Top, Left in parent's
- coords }
- itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer; {
- Size determiners }
- numOfRows: INTEGER; { Number of rows initially
- }
- numOfCols: INTEGER; { Number of columns
- initially }
- rowHeight: INTEGER; { Height of rows, or zero
- for font height }
- colWidth: INTEGER; { Width of items in the
- columns }
- adornRows: BOOLEAN; { Adornment for Rows? }
- adornCols: BOOLEAN; { Adornment for Columns? }
- rowInset: INTEGER; { horizontal space between
- cells }
- colInset: INTEGER; { vertical space between
- cells }
- singleSelection: BOOLEAN; { single cell
- selection? }
- itsTextStyle: TextStyle); { size, color, etc.
- font info }
-
- { Initialize the TextGridView. If numOfRows or numOfCols is non-zero then the
- gridview is initialized to the specified size. The row and height of the cells is
- determine by the font size, style etc. The default size may be changed with calls
- to the the SetRowHeight and SetColWidth methods. If either adorn is kDontAdorn,
- then that adorn will not be called. The "Insets" allow space between cells and may
- be used to draw row and column adornments. }
-
- PROCEDURE TTextGridView.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TTextGridView.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write this object out as a view resource. }
-
- PROCEDURE TTextGridView.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- { Methods To OVERRIDE }
-
- PROCEDURE TTextGridView.GetText(aCell: GridCell;
- VAR aString: Str255);
- { This routine gets the text to be draw in a given cell. IT MUST BE OVERRIDDEN! }
-
- { General Methods }
-
- PROCEDURE TTextGridView.DrawCell(aCell: GridCell;
- aQDRect: Rect); OVERRIDE;
- { Calls GetText and then draws the text }
-
- FUNCTION TTextGridView.Focus: BOOLEAN; OVERRIDE;
- { Calls inherited focus and calls SetUpFont }
-
- PROCEDURE TTextGridView.SetUpFont;
- { Sets up the font for this view. }
-
- PROCEDURE TTextGridView.SetPen;
- { Sets the font characteristics of the current port. Called at the beginning of the
- Draw method.}
-
- PROCEDURE TTextGridView.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- TTextListView = OBJECT (TTextGridView) { This subclass of TTextGridView handles
- lists in a manner similar to the List
- Manager in the toolbox. These lists
- typically consist of single columns and
- the case of this subclass handle the
- placeme { Initialization and Free Methods
- }
-
- PROCEDURE TTextListView.ITextListView(itsDocument: TDocument; { Its document }
- itsSuperView: TView;
- itsLocation: VPoint;
- itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- numOfItems: INTEGER;
- rowHeight: INTEGER; { Height of rows, or zero
- for font height }
- colWidth: INTEGER;
- adornRows: BOOLEAN;
- adornCols: BOOLEAN;
- rowInset: INTEGER;
- colInset: INTEGER;
- singleSelection: BOOLEAN;
- itsTextStyle: TextStyle);
-
- { Initialize the TextListView. If numOfItems is non-zero then the listview is
- initialized to the specified size. The width and height of the items are determined
- by the font size, style etc. The default size may be changed with calls to the the
- SetItemHeight and SetItemWidth methods. The "Insets" allow space between items. }
-
- PROCEDURE TTextListView.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- { Methods To OVERRIDE }
-
- PROCEDURE TTextListView.GetItemText(anItem: INTEGER;
- VAR aString: Str255);
- { Get the text to be drawn for a given item. THIS METHOD MUST BE OVERRIDDEN !! }
-
- FUNCTION TTextListView.CanSelectItem(anItem: INTEGER): BOOLEAN;
- { Determine if the item is selectable }
-
- { General Methods }
- PROCEDURE TTextListView.AllItemsDo(PROCEDURE
- DoToItem(anItem: INTEGER));
- { For all the items in the view perform "DoToItem". }
-
- FUNCTION TTextListView.CanSelectCell(aCell: GridCell): BOOLEAN; OVERRIDE;
- { This method checks to see if a cell can be selected. This method simply calls
- CanSelectItem }
-
- PROCEDURE TTextListView.DelItemAt(anItem: INTEGER;
- numOfItems: INTEGER);
- { Delete the specified items. This causes a redraw of only the necessary cells. }
-
- PROCEDURE TTextListView.DelItemFirst(numOfItems: INTEGER);
- { Delete the specified items. This causes a redraw of only the necessary cells. }
-
- PROCEDURE TTextListView.DelItemLast(numOfItems: INTEGER);
- { Delete the specified items. This causes a redraw of only the necessary cells. }
-
- PROCEDURE TTextListView.EachItemDo(start, stop: INTEGER;
- PROCEDURE
- DoToItem(anItem: INTEGER));
- { For each item in the specified range perform "DoToItem". }
-
- PROCEDURE TTextListView.EachSelectedItemDo(PROCEDURE
- DoToItem(anItem: INTEGER));
- { For each item selected perform "DoToItem". }
-
- FUNCTION TTextListView.GetItemHeight(anItem: INTEGER): INTEGER;
- { Return the height of the specified item. }
-
- FUNCTION TTextListView.GetItemWidth: INTEGER;
- { Return the width of the view. }
-
- PROCEDURE TTextListView.GetText(aCell: GridCell;
- VAR aString: Str255); OVERRIDE;
- { Calls GetItemText with an item number. }
-
- PROCEDURE TTextListView.InsItemBefore(anItem: INTEGER;
- numOfItems: INTEGER);
- { Insert numOfItems before anItem in the list. }
-
- PROCEDURE TTextListView.InsItemFirst(numOfItems: INTEGER);
- { Insert numOfItems at the beginning of the list. }
-
- PROCEDURE TTextListView.InsItemLast(numOfItems: INTEGER);
- { Insert numOfItems at the end of the list. }
-
- FUNCTION TTextListView.IsItemSelected(anItem: INTEGER): BOOLEAN;
- { Check if the specified item is currently selected. }
-
- PROCEDURE TTextListView.Resize(width, height: VCoordinate;
- invalidate: BOOLEAN); OVERRIDE;
- { Resize the view. }
-
- PROCEDURE TTextListView.SelectCell(theCell: GridCell;
- extendSelection, highlight,
- select: BOOLEAN); OVERRIDE;
- { Calls SelectItem with the appropriate item number }
-
- PROCEDURE TTextListView.SelectItem(anItem: INTEGER;
- extendSelection, highlight, select: BOOLEAN);
- { Select the given item. If extend is true then the item is added to the current
- selection. Otherwise the current selection is deselected. If highlight is true then
- the selected item is highlighted.}
-
- PROCEDURE TTextListView.SetItemHeight(anItem: INTEGER;
- numOfItems: INTEGER;
- aHeight: INTEGER);
- { Set the height of an item to be different from the default. This
- changes the height of only the specified items. }
-
- PROCEDURE TTextListView.SetItemWidth(aWidth: INTEGER);
- { Set the width of the view to aWidth. (This changes the width of all
- the items. }
-
- FUNCTION TTextListView.FirstSelectedItem: INTEGER;
- { Returns the first item selected. }
-
- FUNCTION TTextListView.LastSelectedItem: INTEGER;
- { Returns the last item selected. }
-
- PROCEDURE TTextListView.InvalidateItem(anItem: INTEGER);
- { Invalidates the given item, causing it to be redrawn }
-
- PROCEDURE TTextListView.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- TCellSelectCommand = OBJECT (TCommand)
- fGridView: TGridView; { The associated GridView }
- fShiftKey: BOOLEAN; { Shift Key down? }
- fCmdKey: BOOLEAN; { Command Key down? }
- fDeselecting: BOOLEAN;
- fAnchorCell: GridCell;
- fPrevCell: GridCell;
- fThisSelection: RgnHandle;
- fPrevSelection: RgnHandle;
- fDifference: RgnHandle;
-
- PROCEDURE TCellSelectCommand.ICellSelectCommand(itsView: TGridView;
- theShiftKey, theCmdKey: BOOLEAN);
- { Initialize the command object. }
-
- PROCEDURE TCellSelectCommand.Free; OVERRIDE;
- { If the region fPrevSelection and fDifference are not NIL then dispose of them
- before calling inherited Free. }
-
- PROCEDURE TCellSelectCommand.TrackFeedback(anchorPoint, nextPoint: VPoint;
- turnItOn,
- mouseDidMove: BOOLEAN); OVERRIDE;
- { Override this method to give feedback while the mouse button is down. The default
- does nothing. }
-
- FUNCTION TCellSelectCommand.TrackMouse(aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint,
- nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
- { Track the mouse when the button is down. }
-
- PROCEDURE TCellSelectCommand.DoIt; OVERRIDE;
- { The method that will do the actual task to be performed by the command. MUST BE
- OVERRIDDEN. }
-
- PROCEDURE TCellSelectCommand.ComputeAnchorCell(VAR clickedCell: GridCell);
- { Computes the cell that the mouse is first clicked in when making a selection. }
-
- PROCEDURE TCellSelectCommand.ComputeNewSelection(VAR clickedCell: GridCell);
- { Calculate what the new selection should be. }
-
- PROCEDURE TCellSelectCommand.HighlightNewSelection;
- { Highlight the new selection. }
-
- PROCEDURE TCellSelectCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- TRCSelectCommand = OBJECT (TCellSelectCommand)
- { An abstract superclass for row and column selection }
-
- PROCEDURE TRCSelectCommand.ComputeNewSelection(VAR clickedCell: GridCell); OVERRIDE;
- { Computes the new selection. }
-
- FUNCTION TRCSelectCommand.TrackMouse(aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint,
- nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
- { Track the mouse during selection. }
-
- PROCEDURE TRCSelectCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- TRowSelectCommand = OBJECT (TRCSelectCommand) { A subclass that performs selections on
- rows. }
- PROCEDURE TRowSelectCommand.IRowSelectCommand(itsView: TGridView;
- theShiftKey, theCmdKey: BOOLEAN);
- { Initialization of command. }
-
- PROCEDURE TRowSelectCommand.ComputeAnchorCell(VAR clickedCell: GridCell); OVERRIDE;
- { Override of method to perform computations specific to row selection. }
-
- PROCEDURE TRowSelectCommand.ComputeNewSelection(VAR clickedCell: GridCell); OVERRIDE
- ;
- { Override of method to perfom computation of new selection specific to row
- selection. }
- PROCEDURE TRowSelectCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- TColumnSelectCommand = OBJECT (TRCSelectCommand) { A subclass that handles the selection
- of columns in a GridView. }
- PROCEDURE TColumnSelectCommand.IColumnSelectCommand(itsView: TGridView;
- theShiftKey,
- theCmdKey: BOOLEAN);
- { Initialization method. }
-
- PROCEDURE TColumnSelectCommand.ComputeAnchorCell(VAR clickedCell: GridCell);
- OVERRIDE;
- { Override of method to perform computations specific to column selection. }
-
- PROCEDURE TColumnSelectCommand.ComputeNewSelection(VAR clickedCell: GridCell);
- OVERRIDE;
- { Override of method to perform computation of new selection specific to column
- selection. }
-
- PROCEDURE TColumnSelectCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- VAR
- { These are intended to be private, but are in the interface so that you can use these
- regions if you override the methods that use them. }
-
- pPixelsToHighlight: RgnHandle; { Used by HighlightCells }
- pPreviousSelection: RgnHandle; { Used by SetSelection }
- pDifference: RgnHandle; { Used by SetSelection }
- pVisibleCells: RgnHandle; { Used by CellsToPixels }
- pInvalidateRgn: RgnHandle; { Used by InvalidateSelection }
-
- PROCEDURE InitUGridView;
- { Creates all the regions used by the GridView class and then sets the global flag
- 'gUGridViewInitialized'. }
-
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-